import { Table } from 'antd';
import React,{useState} from 'react';


// const Tablea = (props) => <Table columns={columns} dataSource={data} onChange={onChange} />;


const Tablea = (props) => {

  const columns = [
    {
      title: '大棚名称',
      dataIndex: 'name',
      filters: [
        {
          text: '哆啦A梦大棚',
          value: '哆啦A梦大棚',
        },
        {
          text: '蜡笔小新大棚',
          value: '蜡笔小新大棚',
        },
        {
          text: '奥特曼大棚',
          value: '奥特曼大棚',
        },
        {
          text: 'Submenu',
          value: 'Submenu',
          children: [
            {
              text: 'Green',
              value: 'Green',
            },
            {
              text: 'Black',
              value: 'Black',
            },
          ],
        },
      ],
      // specify the condition of filtering result
      // here is that finding the name started with `value`
      onFilter: (value, record) => record.name.indexOf(value) === 0,
      // sorter: (a, b) => a.name.length - b.name.length,
      sortDirections: ['descend'],
    },
    {
      title: '种植品种',
      dataIndex: 'pinzhong',
      onFilter: (value, record) => record.address.indexOf(value) === 0,
    },
    {
      title: '大棚编号',
      dataIndex: 'age',
      defaultSortOrder: 'descend',
      // sorter: (a, b) => a.age - b.age,
    },
    {
      title: '大棚地址',
      dataIndex: 'address',
      onFilter: (value, record) => record.address.indexOf(value) === 0,
    },
    {
      title: '大棚面积',
      dataIndex: 'mianji',
      onFilter: (value, record) => record.address.indexOf(value) === 0,
    },
    {
      title: '播种时间',
      dataIndex: 'times',
      onFilter: (value, record) => record.address.indexOf(value) === 0,
    },
  ];
  var data = [
    {
      key: '1',
      name: '哆啦A梦大棚',
      age: 32,
      address: '北京市北京市东城区',
      pinzhong:'草莓',
      mianji:'23㎡',
      times:'2020-10-20'
    },
    {
      key: '2',
      name: '蜡笔小新大棚',
      age: 32,
      address: '北京市北京市东城区',
      pinzhong:'草莓',
      mianji:'23㎡',
      times:'2020-10-20'
    },
    {
      key: '3',
      name: '奥特曼大棚',
      age: 32,
      address: '北京市北京市东城区',
      pinzhong:'草莓',
      mianji:'23㎡',
      times:'2020-10-20'
    },
    {
      key: '4',
      name: '哆啦A梦大棚',
      age: 32,
      address: '北京市北京市东城区',
      pinzhong:'草莓',
      mianji:'23㎡',
      times:'2020-10-20'
    }
  ];
  const [arr, setArr]=useState(data)
  const onChange = (pagination, filters, sorter, extra) => {
    // console.log('params', pagination, filters, sorter, extra);
    // console.log(this.props)
  };

  // console.log(g);
  if(props.arrs.name){
     var a= props.arrs
    //  setArr(arr.push(a))
    // console.log(arr);
     data.push(a)
    



     
    //  g.push(a)
    //  data= g
  }
 
  return (
    <Table columns={columns} dataSource={data} onChange={onChange} />
  );
}


export default Tablea;